/**
 * FileName: MetaObjectHandlerConfig
 * Author:   sushu
 * Date:     2018/10/10 14:39
 * Description: 自动注入
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package com.supertange.miniapp.wepet.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * <p>
 *   自动注入
 * </p>
 *
 * @author din
 * @create 2018/10/10
 * @since 1.0.0
 */
@Component
public class MetaObjectHandlerConfig implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        setFieldValByName("createDate", LocalDateTime.now(),metaObject);
    }

    /**
     * 已经由navicat根据时间戳更新代替
     * @param metaObject
     */
    @Override
    public void updateFill(MetaObject metaObject) {
        setFieldValByName("updateDate",LocalDateTime.now(),metaObject);
    }
}
